<template>
  <div class="app-container customer-div">
    <el-tabs v-model="activeName" style="margin-top:20px;" type="card">
      <el-tab-pane label="采购货源" name="first" >
         <sourceGoodsSetting ref="sourceGoodsSetting" :nowDate="nowDate" :startDate="startDate" :endDate="endDate" v-if="activeName == 'first'"></sourceGoodsSetting>
      </el-tab-pane>
      <el-tab-pane label="目标设定" name="second" >
         <targetSetting ref="targetSetting" :nowDate="nowDate" :startDate="startDate" :endDate="endDate" v-if="activeName == 'second'"></targetSetting>
      </el-tab-pane>
      <el-tab-pane label="目标确认" name="third" v-if="saleTargetDataConsume || departSaleTargetDataConsume">
          <pumsTargetConfirm ref="pumsTargetConfirm" v-if="activeName == 'third'"></pumsTargetConfirm>
      </el-tab-pane>
      <el-tab-pane label="目标复盘" name="fourth" v-if="canSaleTargetDataSaleCheck">
        <targetReplay ref="targetReplay" v-if="activeName == 'fourth'"></targetReplay>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>

  import targetSetting from "./components/targetSetting";
  import sourceGoodsSetting from "./components/sourceGoodsSetting";
  import pumsTargetConfirm from "./components/pumsTargetConfirm";
  import targetReplay from "./components/targetReplay";
  import {formatDate} from '@/utils/date';
  import store from '@/store'
  import { mapGetters } from 'vuex'

  export default {
    name: "targetAdministration",
    data(){
      return {
        activeName:'first',
        nowDate:'',
        startDate:'',
        endDate:'',
        roles:store.getters.roles ? store.getters.roles : [],

      }
    },
    components : {
      targetSetting,sourceGoodsSetting,pumsTargetConfirm,targetReplay
    },
    computed: {
      ...mapGetters([
        'name',
        'mobile',
        'userId',
        'isMange',
      ]),
      saleTargetDataConsume(){
        if(this.roles.indexOf("saleTargetDataConsume") != -1){
          return true
        }else{
          return false
        }
      },
      canSaleTargetDataSaleCheck(){
        if(this.roles.indexOf("saleTargetDataSaleCheck") != -1 || this.roles.indexOf("saleTargetDataPurchaseCheck") != -1 || this.roles.indexOf("saleTargetDataCheck") != -1){
          return true
        }else{
          return false
        }
      },
      departSaleTargetDataConsume(){
        if(this.roles.indexOf("departSaleTargetDataConsume") != -1){
          return true
        }else{
          return false
        }
      },

    },
    created() {
      this.nowDate = parseInt(Date.parse(new Date())/1000);
      let now = new Date();
      let nowMonth = now.getMonth(); //当前月
      let nowYear = now.getFullYear(); //当前年
      //本月的开始时间
      let monthStartDate = new Date(nowYear, nowMonth, 1);
      //本月的结束时间
      let monthEndDate = new Date(nowYear, nowMonth+1, 0,23,59,59);
      this.startDate = formatDate(monthStartDate, 'yyyy-MM-dd');
      this.endDate = formatDate(monthEndDate, 'yyyy-MM-dd');
      console.log(this.nowDate,'this.nowDate')
    },
    filters: {



    },
    methods:{


    },
  }
</script>

